'use strict';
module.exports = (app) => {
  // 轮播图表
  const { INTEGER, STRING } = app.Sequelize;
  const Carousel = app.model.define('s_carousel', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    user_id: {
      type: INTEGER,
      comment: '用户id',
    },
    project_id: {
      type: INTEGER,
      comment: '项目id',
    },
    photo_id: {
      type: INTEGER,
      comment: '图片id',
      allowNull: false,
    },
    sort: {
      type: STRING,
      comment: '排序',
      defaultValue: 999,
    },
    hyperlink: {
      type: STRING,
      comment: '超链接',
    },
    site_id: {
      type: INTEGER,
      comment: '位置ID',
    },
  });

  Carousel.associate = function () {
    // 一对多链接图片表
    app.model.Tables.Shop.Carousel.hasMany(app.model.Tables.Shop.Photo, {
      foreignKey: 'point_id',
    });
  };

  return Carousel;
};
